package com.wclass.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.wclass.entity.BaseDiscount;
import com.wclass.mapper.BaseDiscountMapper;
import com.wclass.service.IBaseDiscountService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 优惠券管理 服务实现类
 * </p>
 *
 * @author SEN
 * @since 2019-02-25
 */
@Service
public class BaseDiscountServiceImpl extends ServiceImpl<BaseDiscountMapper, BaseDiscount> implements IBaseDiscountService {

    @Override
    public void insertInfo(Long couresId, Long userID, Integer number, Date startDate, Date expireTime, Long amount) {
        BaseDiscount info = new BaseDiscount();
        info.setCrtTime(new Date());
        info.setState(0);
        info.setCourseId(couresId);
        info.setUserId(userID);
        info.setNumber(number);
        info.setStartTime(startDate);
        info.setExpireTime(expireTime);
        info.setAmount(amount);
        info.setNumberDraw(0);
        baseMapper.insert(info);
    }

    @Override
    public List<Integer> selectCountByCourseId(EntityWrapper<BaseDiscount> ew) {
        return baseMapper.selectCountByCourseId(ew);
    }
}
